Remove CONFIG_MAX_TILE

This tool is fully adopted.

Change-Id: I9b2ebd694f3b021e2b85af4ef1b072c9fd05a178
diff --git a/aomenc.c b/aomenc.c
index e15b2d1..8b9d987 100644
--- a/aomenc.c
+++ b/aomenc.c
@@ -428,12 +428,10 @@
 static const arg_def_t tile_rows =
     ARG_DEF(NULL, "tile-rows", 1,
             "Number of tile rows to use, log2 (set to 0 while threads > 1)");
-#if CONFIG_MAX_TILE
 static const arg_def_t tile_width =
     ARG_DEF(NULL, "tile-width", 1, "Tile widths (comma separated)");
 static const arg_def_t tile_height =
     ARG_DEF(NULL, "tile-height", 1, "Tile heights (command separated)");
-#endif
 static const arg_def_t lossless =
     ARG_DEF(NULL, "lossless", 1, "Lossless mode (0: false (default), 1: true)");
 static const arg_def_t enable_cdef =
@@ -1255,14 +1253,12 @@
       config->cfg.sframe_dist = arg_parse_uint(&arg);
     } else if (arg_match(&arg, &sframe_mode, argi)) {
       config->cfg.sframe_mode = arg_parse_uint(&arg);
-#if CONFIG_MAX_TILE
     } else if (arg_match(&arg, &tile_width, argi)) {
       config->cfg.tile_width_count =
           arg_parse_list(&arg, config->cfg.tile_widths, MAX_TILE_WIDTHS);
     } else if (arg_match(&arg, &tile_height, argi)) {
       config->cfg.tile_height_count =
           arg_parse_list(&arg, config->cfg.tile_heights, MAX_TILE_HEIGHTS);
-#endif
 #if CONFIG_FILEOPTIONS
     } else if (arg_match(&arg, &ext_partition, argi)) {
       config->cfg.cfg.ext_partition = !!arg_parse_uint(&arg) > 0;
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 4cf359e..29f60bd 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -314,13 +314,8 @@
       if (extra_cfg->tile_rows != 0) RANGE_CHECK(extra_cfg, tile_rows, 1, 64);
     }
   } else {
-#if CONFIG_MAX_TILE
     RANGE_CHECK_HI(extra_cfg, tile_columns, 6);
     RANGE_CHECK_HI(extra_cfg, tile_rows, 6);
-#else   // CONFIG_MAX_TILE
-    RANGE_CHECK_HI(extra_cfg, tile_columns, 6);
-    RANGE_CHECK_HI(extra_cfg, tile_rows, 2);
-#endif  // CONFIG_MAX_TILE
   }
   RANGE_CHECK_HI(cfg, monochrome, 1);
 
@@ -646,7 +641,6 @@
   oxcf->enable_jnt_comp =
       extra_cfg->use_jnt_comp & extra_cfg->enable_order_hint;
 
-#if CONFIG_MAX_TILE
   oxcf->tile_width_count = AOMMIN(cfg->tile_width_count, MAX_TILE_COLS);
   oxcf->tile_height_count = AOMMIN(cfg->tile_height_count, MAX_TILE_ROWS);
   for (int i = 0; i < oxcf->tile_width_count; i++) {
@@ -655,7 +649,6 @@
   for (int i = 0; i < oxcf->tile_height_count; i++) {
     oxcf->tile_heights[i] = AOMMAX(cfg->tile_heights[i], 1);
   }
-#endif
   oxcf->error_resilient_mode = cfg->g_error_resilient;
   oxcf->frame_parallel_decoding_mode = extra_cfg->frame_parallel_decoding_mode;
 
diff --git a/av1/common/alloccommon.c b/av1/common/alloccommon.c
index f692366..9106070 100644
--- a/av1/common/alloccommon.c
+++ b/av1/common/alloccommon.c
@@ -84,15 +84,9 @@
   // row <m>?" To make that efficient, we generate the rst_last_stripe array.
   int num_stripes = 0;
   for (int i = 0; i < cm->tile_rows; ++i) {
-#if CONFIG_MAX_TILE
     TileInfo tile_info;
     av1_tile_set_row(&tile_info, cm, i);
     const int mi_h = tile_info.mi_row_end - tile_info.mi_row_start;
-#else
-    const int mi_h = ((i + 1) < cm->tile_rows)
-                         ? cm->tile_height
-                         : (cm->mi_rows - i * cm->tile_height);
-#endif
     const int ext_h = RESTORATION_UNIT_OFFSET + (mi_h << MI_SIZE_LOG2);
     const int tile_stripes = (ext_h + 63) / 64;
     num_stripes += tile_stripes;
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index 6ccfedb..fe87b1d 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -451,7 +451,6 @@
   BOUNDARY_TYPE *boundary_info;
   int boundary_info_alloc_size;
 
-#if CONFIG_MAX_TILE
   int max_tile_width_sb;
   int min_log2_tile_cols;
   int max_log2_tile_cols;
@@ -465,10 +464,6 @@
   int tile_col_start_sb[MAX_TILE_COLS + 1];  // valid for 0 <= i <= tile_cols
   int tile_row_start_sb[MAX_TILE_ROWS + 1];  // valid for 0 <= i <= tile_rows
   int tile_width, tile_height;               // In MI units
-#else
-  int log2_tile_cols, log2_tile_rows;  // Used in non-large_scale_tile_coding.
-  int tile_width, tile_height;         // In MI units
-#endif  // CONFIG_MAX_TILE
 
   unsigned int large_scale_tile;
   unsigned int single_tile_decoding;
diff --git a/av1/common/restoration.c b/av1/common/restoration.c
index 46211a7..97fe80c 100644
--- a/av1/common/restoration.c
+++ b/av1/common/restoration.c
@@ -53,7 +53,6 @@
 
 void av1_alloc_restoration_struct(AV1_COMMON *cm, RestorationInfo *rsi,
                                   int is_uv) {
-#if CONFIG_MAX_TILE
   // We need to allocate enough space for restoration units to cover the
   // largest tile. Without CONFIG_MAX_TILE, this is always the tile at the
   // top-left and we can use av1_get_tile_rect(). With CONFIG_MAX_TILE, we have
@@ -80,10 +79,6 @@
   }
   TileInfo tile_info;
   av1_tile_init(&tile_info, cm, tile_row, tile_col);
-#else
-  TileInfo tile_info;
-  av1_tile_init(&tile_info, cm, 0, 0);
-#endif  // CONFIG_MAX_TILE
 
   const AV1PixelRect tile_rect = av1_get_tile_rect(&tile_info, cm, is_uv);
   const int max_tile_w = tile_rect.right - tile_rect.left;
@@ -1273,7 +1268,6 @@
   }
 }
 
-#if CONFIG_MAX_TILE
 // Get the horizontal or vertical index of the tile containing mi_x. For a
 // horizontal index, mi_x should be the left-most column for some block in mi
 // units and tile_x_start_sb should be cm->tile_col_start_sb. The return value
@@ -1294,7 +1288,6 @@
   assert(0);
   return 0;
 }
-#endif
 
 int av1_loop_restoration_corners_in_sb(const struct AV1Common *cm, int plane,
                                        int mi_row, int mi_col, BLOCK_SIZE bsize,
@@ -1309,16 +1302,11 @@
 
   const int is_uv = plane > 0;
 
-// Which tile contains the superblock? Find that tile's top-left in mi-units,
-// together with the tile's size in pixels.
-#if CONFIG_MAX_TILE
+  // Which tile contains the superblock? Find that tile's top-left in mi-units,
+  // together with the tile's size in pixels.
   const int mib_log2 = cm->seq_params.mib_size_log2;
   const int tile_row = get_tile_idx(cm->tile_row_start_sb, mi_row, mib_log2);
   const int tile_col = get_tile_idx(cm->tile_col_start_sb, mi_col, mib_log2);
-#else
-  const int tile_row = mi_row / cm->tile_height;
-  const int tile_col = mi_col / cm->tile_width;
-#endif  // CONFIG_MAX_TILE
 
   TileInfo tile_info;
   av1_tile_init(&tile_info, cm, tile_row, tile_col);
diff --git a/av1/common/tile_common.c b/av1/common/tile_common.c
index 95b739e..179c4f3 100644
--- a/av1/common/tile_common.c
+++ b/av1/common/tile_common.c
@@ -19,8 +19,6 @@
   av1_tile_set_col(tile, cm, col);
 }
 
-#if CONFIG_MAX_TILE
-
 // Find smallest k>=0 such that (blk_size << k) >= target
 static int tile_log2(int blk_size, int target) {
   int k;
@@ -123,43 +121,6 @@
   assert(tile->mi_col_end > tile->mi_col_start);
 }
 
-#else
-
-void av1_tile_set_row(TileInfo *tile, const AV1_COMMON *cm, int row) {
-  tile->mi_row_start = row * cm->tile_height;
-  tile->mi_row_end = AOMMIN(tile->mi_row_start + cm->tile_height, cm->mi_rows);
-}
-
-void av1_tile_set_col(TileInfo *tile, const AV1_COMMON *cm, int col) {
-  tile->mi_col_start = col * cm->tile_width;
-  tile->mi_col_end = AOMMIN(tile->mi_col_start + cm->tile_width, cm->mi_cols);
-}
-
-#define MIN_TILE_WIDTH_MAX_SB 2
-#define MAX_TILE_WIDTH_MAX_SB 32
-
-static int get_min_log2_tile_cols(int max_sb_cols) {
-  int min_log2 = 0;
-  while ((MAX_TILE_WIDTH_MAX_SB << min_log2) < max_sb_cols) ++min_log2;
-  return min_log2;
-}
-
-static int get_max_log2_tile_cols(int max_sb_cols) {
-  int max_log2 = 1;
-  while ((max_sb_cols >> max_log2) >= MIN_TILE_WIDTH_MAX_SB) ++max_log2;
-  return max_log2 - 1;
-}
-
-void av1_get_tile_n_bits(int mi_cols, int *min_log2_tile_cols,
-                         int *max_log2_tile_cols) {
-  const int max_sb_cols =
-      ALIGN_POWER_OF_TWO(mi_cols, MAX_MIB_SIZE_LOG2) >> MAX_MIB_SIZE_LOG2;
-  *min_log2_tile_cols = get_min_log2_tile_cols(max_sb_cols);
-  *max_log2_tile_cols = get_max_log2_tile_cols(max_sb_cols);
-  assert(*min_log2_tile_cols <= *max_log2_tile_cols);
-}
-#endif  // CONFIG_MAX_TILE
-
 void av1_setup_frame_boundary_info(const AV1_COMMON *const cm) {
   BOUNDARY_TYPE *bi = cm->boundary_info;
   int col;
diff --git a/av1/common/tile_common.h b/av1/common/tile_common.h
index 5ffdafe..783f13c 100644
--- a/av1/common/tile_common.h
+++ b/av1/common/tile_common.h
@@ -52,8 +52,6 @@
 AV1PixelRect av1_get_tile_rect(const TileInfo *tile_info,
                                const struct AV1Common *cm, int is_uv);
 
-#if CONFIG_MAX_TILE
-
 // Define tile maximum width and area
 // There is no maximum height since height is limited by area and width limits
 // The minimum tile width or height is fixed at one superblock
@@ -63,7 +61,6 @@
 void av1_get_tile_limits(struct AV1Common *const cm);
 void av1_calculate_tile_cols(struct AV1Common *const cm);
 void av1_calculate_tile_rows(struct AV1Common *const cm);
-#endif
 
 #ifdef __cplusplus
 }  // extern "C"
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index adcfc40..e77847b 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -1459,8 +1459,6 @@
   pool->frame_bufs[cm->new_fb_idx].buf.render_height = cm->render_height;
 }
 
-#if CONFIG_MAX_TILE
-
 // Same function as av1_read_uniform but reading from uncompresses header wb
 static int rb_read_uniform(struct aom_read_bit_buffer *const rb, int n) {
   const int l = get_unsigned_bits(n);
@@ -1531,7 +1529,6 @@
   }
   av1_calculate_tile_rows(cm);
 }
-#endif
 
 static void read_tile_info(AV1Decoder *const pbi,
                            struct aom_read_bit_buffer *const rb) {
@@ -1578,7 +1575,6 @@
       pbi->tile_col_size_bytes = aom_rb_read_literal(rb, 2) + 1;
       pbi->tile_size_bytes = aom_rb_read_literal(rb, 2) + 1;
     }
-#if CONFIG_MAX_TILE
     for (int i = 0; i <= cm->tile_cols; i++) {
       cm->tile_col_start_sb[i] =
           ((i * cm->tile_width - 1) >> cm->seq_params.mib_size_log2) + 1;
@@ -1587,35 +1583,10 @@
       cm->tile_row_start_sb[i] =
           ((i * cm->tile_height - 1) >> cm->seq_params.mib_size_log2) + 1;
     }
-#endif  // CONFIG_MAX_TILE
     return;
   }
 
-#if CONFIG_MAX_TILE
   read_tile_info_max_tile(cm, rb);
-#else
-  int min_log2_tile_cols, max_log2_tile_cols, max_ones;
-  av1_get_tile_n_bits(cm->mi_cols, &min_log2_tile_cols, &max_log2_tile_cols);
-
-  // columns
-  max_ones = max_log2_tile_cols - min_log2_tile_cols;
-  cm->log2_tile_cols = min_log2_tile_cols;
-  while (max_ones-- && aom_rb_read_bit(rb)) cm->log2_tile_cols++;
-
-  if (cm->log2_tile_cols > 6)
-    aom_internal_error(&cm->error, AOM_CODEC_CORRUPT_FRAME,
-                       "Invalid number of tile columns");
-
-  // rows
-  cm->log2_tile_rows = aom_rb_read_bit(rb);
-  if (cm->log2_tile_rows) cm->log2_tile_rows += aom_rb_read_bit(rb);
-
-  cm->tile_width =
-      get_tile_size(cm->mi_cols, cm->log2_tile_cols, &cm->tile_cols);
-  cm->tile_height =
-      get_tile_size(cm->mi_rows, cm->log2_tile_rows, &cm->tile_rows);
-
-#endif  // CONFIG_MAX_TILE
 
   if (cm->tile_rows * cm->tile_cols > 1) {
     // tile size magnitude
diff --git a/av1/decoder/inspection.c b/av1/decoder/inspection.c
index 156d8b2..5ac5b43 100644
--- a/av1/decoder/inspection.c
+++ b/av1/decoder/inspection.c
@@ -43,17 +43,12 @@
   fd->show_frame = cm->show_frame;
   fd->frame_type = cm->frame_type;
   fd->base_qindex = cm->base_qindex;
-#if CONFIG_MAX_TILE
   // Set width and height of the first tile until generic support can be added
   TileInfo tile_info;
   av1_tile_set_row(&tile_info, cm, 0);
   av1_tile_set_col(&tile_info, cm, 0);
   fd->tile_mi_cols = tile_info.mi_col_end - tile_info.mi_col_start;
   fd->tile_mi_rows = tile_info.mi_row_end - tile_info.mi_row_start;
-#else
-  fd->tile_mi_cols = cm->tile_width;
-  fd->tile_mi_rows = cm->tile_height;
-#endif
   fd->delta_q_present_flag = cm->delta_q_present_flag;
   fd->delta_q_res = cm->delta_q_res;
 #if CONFIG_ACCOUNTING
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index ff1dcb0..802074a 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -2198,8 +2198,6 @@
   }
 }
 
-#if CONFIG_MAX_TILE
-
 // Same function as write_uniform but writing to uncompresses header wb
 static void wb_write_uniform(struct aom_write_bit_buffer *wb, int n, int v) {
   const int l = get_unsigned_bits(n);
@@ -2263,7 +2261,6 @@
     assert(height_sb == 0);
   }
 }
-#endif
 
 static void write_tile_info(const AV1_COMMON *const cm,
                             struct aom_write_bit_buffer *saved_wb,
@@ -2292,22 +2289,7 @@
       aom_wb_write_literal(wb, tile_height - 1, 6);
     }
   } else {
-#if CONFIG_MAX_TILE
     write_tile_info_max_tile(cm, wb);
-#else
-    int min_log2_tile_cols, max_log2_tile_cols, ones;
-    av1_get_tile_n_bits(cm->mi_cols, &min_log2_tile_cols, &max_log2_tile_cols);
-
-    // columns
-    ones = cm->log2_tile_cols - min_log2_tile_cols;
-    while (ones--) aom_wb_write_bit(wb, 1);
-
-    if (cm->log2_tile_cols < max_log2_tile_cols) aom_wb_write_bit(wb, 0);
-
-    // rows
-    aom_wb_write_bit(wb, cm->log2_tile_rows != 0);
-    if (cm->log2_tile_rows != 0) aom_wb_write_bit(wb, cm->log2_tile_rows != 1);
-#endif
   }
 
   *saved_wb = *wb;
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index f639a01..6edd1cf 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -277,15 +277,6 @@
 
   assert(cpi->oxcf.superblock_size == AOM_SUPERBLOCK_SIZE_DYNAMIC);
 
-#if !CONFIG_MAX_TILE
-  // for the max_tile experiment there is no common tile_width, tile_height
-  // max_tile assumes tile dimensions are in superblocks (not 64x64 units)
-  assert(IMPLIES(cpi->common.tile_cols > 1,
-                 cpi->common.tile_width % MAX_MIB_SIZE == 0));
-  assert(IMPLIES(cpi->common.tile_rows > 1,
-                 cpi->common.tile_height % MAX_MIB_SIZE == 0));
-#endif
-
 // TODO(any): Possibly could improve this with a heuristic.
 #if CONFIG_FILEOPTIONS
   if (cpi->common.options && !cpi->common.options->ext_partition)
@@ -810,8 +801,6 @@
   av1_rc_update_framerate(cpi, cpi->common.width, cpi->common.height);
 }
 
-#if CONFIG_MAX_TILE
-
 static void set_tile_info_max_tile(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
   int i, start_sb;
@@ -859,8 +848,6 @@
   av1_calculate_tile_rows(cm);
 }
 
-#endif
-
 static void set_tile_info(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
   (void)cm;
@@ -889,7 +876,6 @@
 
     cm->tile_rows = 1;
     while (cm->tile_rows * cm->tile_height < cm->mi_rows) ++cm->tile_rows;
-#if CONFIG_MAX_TILE
     int i;
     for (i = 0; i <= cm->tile_cols; i++) {
       cm->tile_col_start_sb[i] =
@@ -899,24 +885,9 @@
       cm->tile_row_start_sb[i] =
           ((i * cm->tile_height - 1) >> cm->seq_params.mib_size_log2) + 1;
     }
-#endif  // CONFIG_MAX_TILE
   } else {
-#if CONFIG_MAX_TILE
     set_tile_info_max_tile(cpi);
     (void)cm;
-#else
-    int min_log2_tile_cols, max_log2_tile_cols;
-    av1_get_tile_n_bits(cm->mi_cols, &min_log2_tile_cols, &max_log2_tile_cols);
-
-    cm->log2_tile_cols =
-        clamp(cpi->oxcf.tile_columns, min_log2_tile_cols, max_log2_tile_cols);
-    cm->log2_tile_rows = cpi->oxcf.tile_rows;
-
-    cm->tile_width =
-        get_tile_size(cm->mi_cols, cm->log2_tile_cols, &cm->tile_cols);
-    cm->tile_height =
-        get_tile_size(cm->mi_rows, cm->log2_tile_rows, &cm->tile_rows);
-#endif  // CONFIG_MAX_TILE
   }
 }
 
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 7f4887d..019ad73 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -255,12 +255,10 @@
 
   int tile_columns;
   int tile_rows;
-#if CONFIG_MAX_TILE
   int tile_width_count;
   int tile_height_count;
   int tile_widths[MAX_TILE_COLS];
   int tile_heights[MAX_TILE_ROWS];
-#endif
 
   int max_threads;
 
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index 361e742..98f1efb 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -103,7 +103,6 @@
 set(CONFIG_HASH_ME 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_INTER_STATS_ONLY 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_LOWPRECISION_BLEND 1 CACHE NUMBER "AV1 experiment flag.")
-set(CONFIG_MAX_TILE 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_MONO_VIDEO 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_OBU_FRAME 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_OBU_NO_IVF 0 CACHE NUMBER "AV1 experiment flag.")